package com.google.code.swingonfire.utility.date;

import java.awt.Font;
import java.awt.font.FontRenderContext;
import java.util.Locale;

public class DateRendererContext
{

    private final Font font;
    private final FontRenderContext fontRenderContext;
    private final Locale locale;

    public DateRendererContext(Font font, FontRenderContext fontRenderContext, Locale locale)
    {
        super();
        
        this.font = font;
        this.fontRenderContext = fontRenderContext;
        this.locale = locale;
    }

    public Font getFont()
    {
        return font;
    }

    public FontRenderContext getFontRenderContext()
    {
        return fontRenderContext;
    }

    public Locale getLocale()
    {
        return locale;
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public int hashCode()
    {
        final int prime = 31;
        int result = 1;

        result = (prime * result) + ((font == null) ? 0 : font.hashCode());
        result = (prime * result) + ((fontRenderContext == null) ? 0 : fontRenderContext.hashCode());
        result = (prime * result) + ((locale == null) ? 0 : locale.hashCode());

        return result;
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public boolean equals(Object obj)
    {
        if (this == obj)
        {
            return true;
        }

        if (obj == null)
        {
            return false;
        }

        if (getClass() != obj.getClass())
        {
            return false;
        }

        DateRendererContext other = (DateRendererContext) obj;

        if (font == null)
        {
            if (other.font != null)
            {
                return false;
            }
        }
        else if (!font.equals(other.font))
        {
            return false;
        }

        if (fontRenderContext == null)
        {
            if (other.fontRenderContext != null)
            {
                return false;
            }
        }
        else if (!fontRenderContext.equals(other.fontRenderContext))
        {
            return false;
        }

        if (locale == null)
        {
            if (other.locale != null)
            {
                return false;
            }
        }
        else if (!locale.equals(other.locale))
        {
            return false;
        }

        return true;
    }

}
